home *** CD-ROM | disk | FTP | other *** search
- Program Fire;
-
- { This code was TOTALLY developped by Ricardo M. Oliveira aka Scorpio,
- having in thought the various approaches known to this effect...
- Altough the code was totally developped by Scorpio, Spellcaster cleaned
- it up a little and made it compatible with previous 'The Mag' issues.
- This MAY NOT (and I do not intend it to be) the BEST one or the FASTEST
- one... It is incredibly slow, too... It is even slower because Spellcaster
- tweaked it to work with the Mode13h Unit... That is f#$%&% slow !!! :)
- Its purpose is merely to show how it's done.
- This source MAY be ripped in EVERY way known to man... The ONLY thing I
- ask for is that you PLZ greet me in your demo/intro/whatever... If you have
- questions, feel free to email me...
- Email:
- o questions: si17899@ci.uminho.pt
- o flames: logname@hostname :)
-
- Homepage:
- o htpp://wwwalu.ci.uminho.pt:8888/~si17899
- }
-
- Uses Crt,Mode13h;
-
- { Needed 'coz of KEYPRESSED only... Don't have time to cut 'n' paste
- from my utils unit... Maybe next time... }
-
- Var Pal:RGBList;
- Average:Byte; { ????? :) }
- X,Y:Integer; { Vars needed in the loops below }
- Seed:Byte;
-
- Procedure Hot_Spots;
- { Produces the hotspots of the bottom line of the fire with a random colour... }
- Var I,C1,C2:Integer;
- Begin
- For I:=1 To 100 Do { Why 100? This could be any number... This one
- just looks good... It is the number of hot_spots
- to set. }
- Begin
- C1:=Random(255); { Random color to put in each hot spot. }
- PutPixel(70+random(180),100,c1,VGA);
- { WHAT ??? Why 100 ? And why from 70+random(180) ???
- To speed things up a little, the fire starts at X=70 and ends
- at X=250 and goes from Y=100 to Y=40... }
- End;
- End;
-
- Begin
- Randomize;
- InitGraph;
- LoadPal('FIRE.PAL',Pal);
- SetPalette(Pal);
- Hot_Spots;
- Repeat
- Y:=100;
- Repeat
- For X:=70 To 250 Do
- Begin
- { Get the average from the sum of the point we're
- calculating... Let's see... This is it:
-
- + X is the point we're calculating...
- +X+ We add the value from the three +'s and from
- the X itself and div by 4 ?!?!... :-)
- }
- average:= (GetPixel(X-1,Y,VGA)+
- GetPixel(X,Y,VGA)+
- GetPixel(X+1,Y,VGA)+
- GetPixel(X,Y-1,VGA)) Div 4;
-
- If Y>75 Then
-
- { Ok... The next part may be a bit confusing... We have two different effects
- here: The effect that takes place BELOW y=75 and the one that takes place
- ABOVE y=75... If you look at the fire, you'll see that at a certain height
- it starts to spread itself... That is the second effect...
- Try to change the effects (one in the place of the other, or one of them
- in the whole flame to see the differences... This is just a question of
- playing with random numbers and the placement of the result for each pixel...
- Below is another one, that is commented... try it. Just uncoment it and
- comment the original... }
-
- If Average>8 Then PutPixel(X,Y-1,Average-1,VGA)
- Else PutPixel(X,Y-1,Average,VGA)
- Else
- If Average>8 Then PutPixel(X+Random(3)-1,Y-1,Average-1,VGA)
- Else PutPixel(X-1,Y-1,Average,VGA);
-
- { Strong wind from the right :) }
- { If Average>8 Then PutPixel(X+Random(2)-1,Y-1,Average-1,VGA)
- Else PutPixel(X+Random(2)-1,Y-1,Average,VGA); }
-
- End;
- Dec(Y,1);
- Until Y=40; { As I have said before, I am trying to speed this up
- and keep the code easy to understand... The fire also
- goes from line 100 (base) to line 40 (top of the fire) }
-
- Hot_Spots;
- Until KeyPressed;
- CloseGraph;
-
- { These are my greetz... in NO PARTICULAR ORDER other than the one my
- confusing mind gave me. }
-
- TextColor(LightGray);
- WriteLn('The old fire routine, one more time... ');
- Write('By: ');
- TextColor(LightBlue); Write('Ricardo M. Oliveira ');
- TextColor(LightGray); Write('aka');
- TextColor(Yellow); WriteLn(' Scorpio');
- TextColor(LightGray); write('Email: ');
- TextColor(White); Writeln('si17899@ci.uminho.pt');
- TextColor(LightGray); Writeln('Greetz go to:');
- TextColor(White);
- Writeln('Spellcaster, Cpt Hook, DUF and RD members, NSJ, Virtual Fantasies members,');
- Writeln('everybody from LESI (You know who you are), Virus and Jony_Bigodes :))),');
- Writeln('and *everybody* in Moosaico at University of Minho.');
- End.
-